}
let mut with_cfg = process.clone();
+ with_cfg.arg("--print=sysroot");
with_cfg.arg("--print=cfg");
- let mut has_cfg = true;
+ let mut has_cfg_and_sysroot = true;
let output = with_cfg.exec_with_output().or_else(|_| {
- has_cfg = false;
+ has_cfg_and_sysroot = false;
process.exec_with_output()
}).chain_error(|| {
human(format!("failed to run `rustc` to learn about \
map.insert(crate_type.to_string(), Some((prefix.to_string(), suffix.to_string())));
}
- let cfg = if has_cfg {
- Some(try!(lines.map(Cfg::from_str).collect()))
- } else {
- None
- };
-
- if let Some(ref sysroot) = self.config.rustc()?.sysroot {
- let mut rustlib = sysroot.clone();
+ if has_cfg_and_sysroot {
+ let line = match lines.next() {
+ Some(line) => line,
+ None => bail!("output of --print=sysroot missing when learning about \
+ target-specific information from rustc"),
+ };
+ let mut rustlib = PathBuf::from(line);
if kind == Kind::Host {
if cfg!(windows) {
rustlib.push("bin");
rustlib.push("lib");
self.compilation.target_dylib_path = Some(rustlib);
}
+ }
+
+ let cfg = if has_cfg_and_sysroot {
+ Some(try!(lines.map(Cfg::from_str).collect()))
+ } else {
+ None
};
let info = match kind {
pub wrapper: Option<PathBuf>,
pub verbose_version: String,
pub host: String,
- pub sysroot: Option<PathBuf>,
}
impl Rustc {
triple.to_string()
};
- let sysroot = {
- let mut cmd = util::process(&path);
- cmd.arg("--print=sysroot");
- cmd.exec_with_output().ok()
- .and_then(|output| String::from_utf8(output.stdout).ok() )
- .map(|s| PathBuf::from(s.trim()))
- };
-
Ok(Rustc {
path: path,
wrapper: wrapper,
verbose_version: verbose_version,
host: host,
- sysroot: sysroot
})
}